package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class read {
	private File file = null;
	private static BufferedReader br = null;
	private static String line = null;
	private int lineNum;
	public read() {};
	
	
	public read(File file){
		this.file = file;
		init();
	}
	
	public read(String file) {
		this.file = new File(file);
		init();
	}
	private void init() {
		try {
			br = new BufferedReader(new InputStreamReader(
					new FileInputStream(file)));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
	public static void main(String[] args)  {
		StringBuffer sb = new StringBuffer();
		sb.getClass().getResource("/");
		System.out.println("sb.getClass().getResource('/')"+sb.getClass().getResource("/"));
		read fr = new read(new File("d:/line.txt"));
		try {
			while((line=br.readLine())!=null) {
//					sb.append(line+"\r\n");
					System.out.println(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
//		for(int i=0;i<10;i++) {
//			System.out.println(fr.getNextLine(100,true));
//			
//		}
		
	}
//	public String getNextLine(int count,boolean hasNum) {
//		
//		StringBuffer sb = new StringBuffer();
//		int i = 0;
//		System.out.println("*********************************"+i);
//		try {
//			while((line=br.readLine())!=null) {
//				i++;
//				if(i<=count) {
//					if(hasNum) sb.append(lineNum+i+"\t");
//					sb.append(line+"\r\n");
//					System.out.println(sb.toString());
//				}else break;
//			}
////			System.out.println("------->"+sb.toString());
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		lineNum += i-1;
//		return sb.toString();
//	}
}
